17 Lecture
CS201
Midterm & Final Term Short Notes
String Handling
String handling is an important concept in C programming, as it involves working with strings of characters. String handling functions allow us to manipulate and work with strings in various ways, such as copying, concatenating, and comparing st
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is the standard library function to compare two strings? a) strcat() b) strcmp() c) strlen() d) strcpy() Answer: b) strcmp()
What is the standard library function to find the length of a string? a) strcat() b) strcmp() c) strlen() d) strcpy() Answer: c) strlen()
Which function can be used to convert a string to a floating-point number? a) atof() b) atoi() c) atol() d) strtof() Answer: a) atof()
Which function is used to concatenate two strings? a) strcat() b) strcmp() c) strlen() d) strcpy() Answer: a) strcat()
Which function is used to copy one string to another? a) strcat() b) strcmp() c) strlen() d) strcpy() Answer: d) strcpy()
What is the maximum length of a string in C? a) 255 characters b) 256 characters c) 512 characters d) There is no maximum length Answer: d) There is no maximum length
Which function can be used to find the first occurrence of a character in a string? a) strchr() b) strrchr() c) strstr() d) strcmp() Answer: a) strchr()
What is the standard library function to convert a string to an integer? a) atoi() b) atof() c) atol() d) strtoi() Answer: a) atoi()
Which function can be used to extract a substring from a string? a) strtok() b) strspn() c) strcspn() d) strncpy() Answer: d) strncpy()
What is the standard library function to convert an integer to a string? a) itoa() b) atoi() c) ltoa() d) strtoi() Answer: a) itoa()
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is a string in C programming? How is it different from a character array? Ans: A string is a sequence of characters terminated by a null character '\0'. It is a built-in data type in C language. A character array is a collection of characters. The difference between a string and a character array is that a string is terminated by a null character whereas a character array is not.
How can you input a string in C programming? Ans: We can input a string in C programming using the 'gets' function or the 'scanf' function with '%s' format specifier.
How can you output a string in C programming? Ans: We can output a string in C programming using the 'puts' function or the 'printf' function with '%s' format specifier.
How can you find the length of a string in C programming? Ans: We can find the length of a string in C programming using the 'strlen' function.
How can you concatenate two strings in C programming? Ans: We can concatenate two strings in C programming using the 'strcat' function.
How can you compare two strings in C programming? Ans: We can compare two strings in C programming using the 'strcmp' function.
How can you copy one string into another in C programming? Ans: We can copy one string into another in C programming using the 'strcpy' function.
What is a substring in a string? How can you extract a substring from a string in C programming? Ans: A substring is a portion of a string. We can extract a substring from a string in C programming using the 'strncpy' function or the 'strstr' function.
How can you convert a string to an integer in C programming? Ans: We can convert a string to an integer in C programming using the 'atoi' function.
How can you convert an integer to a string in C programming? Ans: We can convert an integer to a string in C programming using the 'sprintf' function.